<#    
    .PARAMETER CssDebug
    If set to true, will output pretty JS for debugging with r.js
    .PARAMETER Debug
    If set to true, will output pretty JS and pretty CSS
    .PARAMETER Swtk
    If set to true, will compile all .swtk files
    .PARAMETER Less
    If set to true, will compile all .less files
    .PARAMETER Clean
    If set to true, will clean all generated files.
#>

PARAM(
    [Parameter(HelpMessage = "Output debug CSS?")]
    [Switch]
    $CssDebug = $False,
    [Parameter(HelpMessage = "Output debug everything?")]
    [Switch]
    $DebugAll = $False,
    [Parameter(HelpMessage = "Compile SWTK templates?")]
    [Switch]
    $Swtk = $True,
    [Parameter(HelpMessage = "Compile Less?")]
    [Switch]
    $Less = $True,
    [Parameter(HelpMessage = "Clean all generated files")]
    [Switch]
    $Clean = $False
    
)

if ($Clean)
{
    Write-Warning "Cleaning!";
    perl .\swtk.pl -c .\default.cfg --clean
    Remove-Item .\data\stylesheets -Force -Recurse -ErrorAction SilentlyContinue
    Exit;
}

if ($DebugAll)
{
    $CSSDebug = $True;
}

# Compile SWTK stuff
if ($Swtk)
{
    perl .\swtk.pl -c .\default.cfg -v
    Remove-Item -force .\data\sitemap.xml
}

# Compile CSS with Less
if ($Less)
{
    $lessparam = "-x"
    if ($CssDebug)
    {
        $lessparam = "";
    }
    Write-Host "Compiling .less";
    if (!(Test-Path .\data\stylesheets))
    {
        Write-Warning ".\data\stylesheets does not exist. Creating...";
        New-Item -Type Directory -Path .\data\stylesheets
    }
    & lessc $lessparam .\swtk-data\stylesheets\style.less .\data\stylesheets\style.css
    & lessc $lessparam .\swtk-data\stylesheets\style.print.less .\data\stylesheets\style.print.css
}